package gwtI18nEditor.datamodel;

public class Translation {
	
	private final Message parent;
	private final Locale  locale;
	private String message;
	
	public Translation(Message parent, Locale locale, String message) {
		this.parent  = parent;
		this.locale  = locale;
		this.message = message;
	}

	public Locale getLocale() {
		return locale;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		boolean oldNA = needsAttention();
		this.message = message;
		if (oldNA!=needsAttention()) parent.reCheck();
	}
	
	public boolean needsAttention() {
		return (message==null) || message.isEmpty();
	}
	
	public String toString() {
		return (locale==null) ? "<default>" : locale.getDescription();
	}
}
